Skip to content

Conversation

@michaelgruenewald
Copy link
Contributor

@michaelgruenewald michaelgruenewald commented Oct 13, 2025

This adds an exported API for other extensions to add rust-analyzer-specific configurations for #18476. It provides a simple API where an extension can just call something like

const rustAnalyzer = await vscode.extensions.getExtension("rust-lang.rust-analyzer")?.activate();
await rustAnalyzer?.addConfiguration(ctx.extension.id, {
    "cargo.cfgs": ["foo", "bar"],
});

to configure aspects. The extension configurations are persisted in the workspace, but only configurations from extensions are are actually present are used, so that uninstalled extensions, etc. aren't causing any trouble.

This does pull in lodash as a dependency, but IMO this is neither very heavy nor critical, and it was already in the dev closure anyway.

Also cf. the discussion in https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/VSCode.20extension.20config.20feature.20contribution

Fixes #18476

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 13, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 13, 2025
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits labels Oct 13, 2025
@michaelgruenewald michaelgruenewald changed the title Add a Extension Config API Add an Extension Config API Oct 14, 2025
readonly rootSection = "rust-analyzer";
private readonly requiresServerReloadOpts = ["server", "files", "showSyntaxTree"].map(
private readonly rootSection = "rust-analyzer";
private readonly requiresServerReloadOpts = ["cargo", "server", "files", "showSyntaxTree"].map(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch, that was for an unrelated issue.

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril added this pull request to the merge queue Oct 26, 2025
Merged via the queue into rust-lang:master with commit b0b108c Oct 26, 2025
16 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 26, 2025
@lnicola
Copy link
Member

lnicola commented Oct 26, 2025

changelog feat (first contribution) expose an addConfiguration API from the Code extension

mendelsshop pushed a commit to mendelsshop/rust-analyzer that referenced this pull request Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code Extension Config API

4 participants